import org.apache.spark.sql.SparkSession

object Connect {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder()
      .appName("RDDPartitionExample")
      .master("local[*]")
      .getOrCreate()
    val sc = spark.sparkContext

    val rdd1 = sc.parallelize(List(('a', 1),('b', 2),('c', 3)))
    val rdd2 = sc.parallelize(List(('a', 1),('b', 4),('c', 5)))

    val j_rdd = rdd1.join(rdd2)
    println(j_rdd.collect().mkString(","))

    val right_join = rdd1.rightOuterJoin(rdd2)
    println(right_join.collect().mkString(","))

    val left_join = rdd1.leftOuterJoin(rdd2)
    println(left_join.collect().mkString(","))

    val full_join = rdd1 .fullOuterJoin(rdd2)
    println(full_join.collect().mkString(","))

  }
}
